﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace shuatibao.Tool
{
    public class SQLTool
    {
        #region 获取列表方法
        public static DataRowCollection sqlGetListManager(string sql) {
            SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
            sqlcon.Open();
            //查询列表信息
            DataTable dt = new DataTable();
            SqlDataAdapter dap = new SqlDataAdapter(sql, sqlcon);
            dap.Fill(dt);
            
            sqlcon.Close();

            return dt.Rows;
        }

        #endregion



        public static SqlDataReader sqlGetInfo(string sql) {
            SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
            sqlcon.Open();

            SqlCommand sqlcmd = new SqlCommand(sql, sqlcon);
            SqlDataReader dr = sqlcmd.ExecuteReader();
            sqlcon.Close();
        
            return dr;
           
          
        }



        #region 修改
        public static void sqlUpdateInfo(string sql)
        {
            //连接数据库
            SqlConnection sqlcon1 = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
            sqlcon1.Open();
       
            SqlCommand cmd = new SqlCommand(sql, sqlcon1);
            //添加参数并且设置参数值
            cmd.ExecuteNonQuery();
            sqlcon1.Close();

        }
        #endregion


    }

}